package hos.http.converter;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * <p>Title: HttpConvertString </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @version : 1.0
 * @date : 2023/4/4 18:06
 */
public abstract class HttpStringJsonDataConvert extends HttpStringJsonConvert {

    protected String data = "data";

    public HttpStringJsonDataConvert() {
        this("data");
    }

    public HttpStringJsonDataConvert(String data) {
        super();
        this.data = data;
    }

    public HttpStringJsonDataConvert(String success, String code, String message) {
        super(success, code, message);
    }

    public HttpStringJsonDataConvert(String success, String code) {
        super(success, code);
    }

    public HttpStringJsonDataConvert(String success, String code, String data, String message) {
        super(success, code, message);
        this.data = data;
    }

    @Override
    public <D> D parseJson(Type succeed, String json) throws IOException {
        String requireJson = HttpConverterUtils.requireJsonData(json, json, success, code, message, data);
        return parseBody(succeed, requireJson);
    }

}
